// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// State definitions for entropy_src_main_sm, provided as a separate package for use in DV

package entropy_src_main_sm_pkg;

  // Encoding generated with:
  // $ ./util/design/sparse-fsm-encode.py -d 3 -m 20 -n 9 \
  //     -s 2359261201 --language=sv
  //
  // Hamming distance histogram:
  //
  //  0: --
  //  1: --
  //  2: --
  //  3: |||||||||||| (18.42%)
  //  4: |||||||||||||||||||| (29.47%)
  //  5: |||||||||||||||||| (26.84%)
  //  6: ||||||||||| (16.32%)
  //  7: |||| (6.84%)
  //  8: | (2.11%)
  //  9: --
  //
  // Minimum Hamming distance: 3
  // Maximum Hamming distance: 8
  // Minimum Hamming weight: 1
  // Maximum Hamming weight: 8
  //
  localparam int StateWidth = 9;
  typedef enum logic [StateWidth-1:0] {
    Idle           = 9'b011110101, // idle
    BootHTRunning  = 9'b111010010, // boot mode, wait for health test done pulse
    BootPostHTChk  = 9'b101101110, // boot mode, wait for post health test packer not empty state
    BootPhaseDone  = 9'b010001110, // boot mode, stay here until master enable is off
    StartupHTStart = 9'b000101100, // startup mode, pulse the sha3 start input
    StartupPhase1  = 9'b100000001, // startup mode, look for first test pass/fail
    StartupPass1   = 9'b110100101, // startup mode, look for first test pass/fail, done if pass
    StartupFail1   = 9'b000010111, // startup mode, look for second fail, alert if fail
    ContHTStart    = 9'b001000000, // continuous test mode, pulse the sha3 start input
    ContHTRunning  = 9'b110100010, // continuous test mode, wait for health test done pulse
    FWInsertStart  = 9'b011000011, // fw ov mode, start the sha3 block
    FWInsertMsg    = 9'b001011001, // fw ov mode, insert fw message into sha3 block
    Sha3MsgDone    = 9'b100001111, // sha3 mode, sha3 state cleared, go to continuous check mode
    Sha3Process    = 9'b011111000, // sha3 mode, pulse the sha3 process input
    Sha3Valid      = 9'b010111111, // sha3 mode, wait for sha3 valid indication
    Sha3Done       = 9'b110011000, // sha3 mode, capture sha3 result, pulse done input
    AlertState     = 9'b111001101, // if some alert condition occurs, pulse an alert indication
    AlertHang      = 9'b111111011, // after pulsing alert signal, hang here until sw handles
    Error          = 9'b001110011  // illegal state reached and hang
  } state_e;

endpackage
